<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    <style>
		table img{width: 40px}
	</style>
<body style="">    
  <br/>
  
      <h5>备货申请单:<?php echo $info['name'];?></h5>
      <h5>发起人:<?php echo $info['user'];?></h5>
  	申请单备注:<?php echo $info['remarkes'];?>
         <br/>

  采购类型: <input  id='cgtype'   readonly="readonly"   name="" showNullItem="true" class="mini-combobox" value="<?php echo $info['type']?>" data="[{'id':1,'text':'集采'},{'id':2,'text':'非常规'},{'id':3,'text':'常规'}]" valueField="id" textField="text"  onValuechanged='cgfschange' />
  采购负责人: <input  id='cplist'  readonly="readonly"  name="" showNullItem="true" class="mini-combobox" value="<?php echo $info['manager']?>" url="/stocking/getUser?type=1" valueField="id" textField="text"/><br/><br/>

      供应商:<input readonly="readonly"  id="gys" class="mini-textbox" value="<?php echo $info['suppliers_name']?>" name="" textName="" style="width: 200px"/>


      <!--营销负责人: <input id='salelist'   readonly="readonly" name="" showNullItem="true" class="mini-combobox"  value="<?php echo $info['sale']?>" url="/stocking/getUser?type=2" valueField="id" textField="text"  style="width: 170px"/>-->
     到货时间:<input property="" class="mini-datepicker" valueType='string' style="width:200px;" format="yyyy-MM-dd" id='storage_time' value="<?php echo $info['storage_time']?>" />
  SAP采购员: <input id='receipter'  readonly="readonly" name="" showNullItem="true" class="mini-combobox" url="/stocking/getreceipter" valueField="slpcode" textField="SlpName"  value="<?php echo $info['receipterCode']?>" style="width: 200px"/>
    <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
    buttons="#tabsButtons"
>
    <div title="备货清单" >
   
   <div id="datagrid1" class="mini-datagrid" style="height:400px;width: 100%;" 
    allowCellEdit="false" allowCellSelect="true" multiSelect="false"
        allowCellValid="true" oncellvalidation="onCellValidation" url="/Stocking/getinfo" showPager='false'
   >
    
        <div property="columns">
           
             <div field="item_code"  headerAlign="center"  >物料号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>    
            
             <div field="item_name"  headerAlign="center" width='300px' >物料名称
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>           
            
            <div field="suppliers_name"  headerAlign="center"  >供应商
                <input property="editor" class="mini-textbox" style="width:100%;" onclick="onButtonEdit2" />
            </div> 
              <div field="suppliers_code"  headerAlign="center"  style="" >供应商编号
                <input property="editor" class="mini-textbox" style="width:100%;"  onclick="onButtonEdit2" />
            </div> 
            
            <div field="p_price"  headerAlign="center"  >本次采购价格
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
                <div field="previous_price"  headerAlign="center"  >上次采购价格
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
            <div field="warehouse"  headerAlign="center"   type="comboboxcolumn" autoShowPopup="true" >仓库
               <input property="editor" class="mini-combobox" style="width:100%;" data="whouselist" />         
            </div> 
            
            
               <div field="change_price"  headerAlign="center"  >价格变动率(%)
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
            
               <div field="amout"  headerAlign="center"  >申请备货数量
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
               <div field="total_price"  headerAlign="center"  >备货金额
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
            <div field="r_inventory"  headerAlign="center"  >建议安全库存
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="current_inventory"  headerAlign="center"  >在库库存
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="transit_inventory"  headerAlign="center"  >在途库存
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="available_inventory"  headerAlign="center"  >可用库存
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
        <!--    <div field="storage_time"   headerAlign="center"  >到货日期
                <input property="editor" class="mini-datepicker" valueType='string' style="width:100%;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" />
            </div> -->
            
             <div field="lately_15"  headerAlign="center"  >近15天销量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
            
             
             <div field="lately_30"  headerAlign="center"  >前30天销量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="taotal_sales"  headerAlign="center"  >累计销量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>

            <div field="suggestorder"  headerAlign="center"  >建议备货数量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>

            <div field="availableday"  headerAlign="center"  >可用库存天数
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>

            <div field="avgbuyday"  headerAlign="center"  >平均订货天数
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>

            <div field="avgdaliysale"  headerAlign="center"  >平均日销量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>

            <div field="minsafe"  headerAlign="center"  >最低安全库存
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            
              <div field="remarks"  headerAlign="center"  >备注
                  <input property="editor" class="mini-textarea" style="width:200px;" minWidth="200" minHeight="50"/>
            </div>

           
        </div>
    </div>
    
    </div>
    <!-- <div title="Tab2" iconCls="" >
        2
    </div> -->
</div>
  <div id='editForm1'>
   <?php if(isset($access)&&$access){?>
    <br/>
             备注: <input id="remarkes" class="mini-textarea" style="width:400px;" minWidth="200" minHeight="100" value="" />
    <br/> <br/>

      <if condition="$urgentEnable">
          <div>
          <a class="mini-button" onclick="urgentEnable(1)"  id='query-bt' style="background-color: #81de81;color: white;width: 205px;height: 30px;line-height: 30px;font-weight: bold;" >&nbsp;&nbsp;加急&nbsp;&nbsp;</a>
          </div>
      </if>
   
    <a class="mini-button" onclick="review(1)" id='query-bt' style="background-color: #81de81;color: white;width: 100px;height: 30px;line-height: 30px;font-weight: bold;" >&nbsp;&nbsp;通过&nbsp;&nbsp;</a>
    <a class="mini-button" onclick="review(-1)"  id='query-bt' style="background-color: #de4c2b;color: white;width: 100px;height: 30px;line-height: 30px;font-weight: bold;" >&nbsp;&nbsp;不通过&nbsp;&nbsp;</a>
    <?php };?>
  </div>
  <h4>操作记录</h4>
  <ul>
  <?php foreach($log as $vo ){?>
  <li><?php echo $vo['user'].'在'. $vo['ctime'].' '.$vo['info'] ;?></li>
  <?php }?>
  </ul>
  
</body>
<script type="text/javascript">
        mini.parse();
        var whouselist = [{ id: 'HYWCK', text: '昆山实体仓库' }, { id: 'A07', text: '样品仓库'},{ id: 'A02', text: '虚拟卡券'},{ id: 'JDGD', text: '京东光大仓'}];
        var grid = mini.get("datagrid1");
        grid.load({id:<?php echo $info['id'];?>});
        
        grid.on("drawcell", function (e) {
        var record = e.record,
        column = e.column,
        field = e.field,
        value = e.value;
            //格式化日期
            if (field == "storage_time") {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
				
            }
            
            if (field == "amout"||field == "total_price"||field=="storage_time"||field=="p_price") {
        		  e.cellStyle = "background:#ecedef";
              }

        });

 		function review(status){
 			
 		        mini.confirm("确定要执行该操作吗？", "确定?",
 		            function (action) {
 		                if (action == "ok") {
 		                	doreview(status);
 		                } else {
 		                   
 		                }
 		            }
 		        );
 		    
 			
 		}
        function doreview(status) {
    
             mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            }); 
             
            var  remarkes = mini.get('remarkes').getValue();
             
            $.ajax({
                url: "/Stocking/review",
                data: { id: <?php echo $info['id']?>,status:status,remarkes:remarkes},
                type: "post",
                dataType:'json',
                success: function (data) {
                   if(data.code==0){
                	    mini.unmask(document.body);
						mini.alert('保存成功!');
						location.reload();   
						return ;
                   }else{
                	   mini.unmask(document.body);
                	   mini.alert(data.msg);
                       }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }


        function urgentEnable(status){

            mini.confirm("确定要执行该操作吗？", "确定?",
                function (action) {
                    if (action == "ok") {
                        doUrgentEnable(status);
                    } else {

                    }
                }
            );


        }
        function doUrgentEnable(status) {

            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            });

            var  remarkes = mini.get('remarkes').getValue();

            $.ajax({
                url: "/Stocking/doUrgentEnable",
                data: { id: <?php echo $info['id']?>,status:status,remarkes:remarkes},
            type: "post",
                dataType:'json',
                success: function (data) {
                if(data.code==0){
                    mini.unmask(document.body);
                    mini.alert('保存成功!');
                    location.reload();
                    return ;
                }else{
                    mini.unmask(document.body);
                    mini.alert(data.msg);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
        }

    </script>
  
</body>
</block>
<block name="js">
	<script type="text/javascript">

	</script>
</block>